﻿using System;
using System.Collections.Generic;

using System.Configuration;

namespace EHSubmit.Util
{

    /// <summary>
    /// 配置帮助
    /// </summary>
    public class ConfigHelper
    {
        /// <summary>
        /// 获得当前学期
        /// </summary>
        /// <returns></returns>
        public static string GetTerm()
        {
            string term = ConfigurationManager.AppSettings["CurrentTerm"] as string;
            if (term == null)
            {
                throw new ConfigException("系统配置错误:CurrentTerm未配置");
            }
            return term;
        }


        /// <summary>
        /// 获得配置的默认每页记录数
        /// </summary>
        /// <returns></returns>
        public static int GetDefaultPageSize()
        {
            int size = EHSubmit.Logic.Constants.DEFAULT_PAGE_SIZE;
            try
            {
                size = int.Parse(ConfigurationManager.AppSettings["DefaultPageSize"]);
            }
            catch (Exception e)
            {
                LogHelper.Log(e.Message, e);
            }

            return size;

        }
    }
}
